#include "CocoaTemplate.h"

/* work around silly mprep bug */
#ifdef __CONDITIONALMACROS__
#undef __CONDITIONALMACROS__
#endif

:Evaluate: BeginPackage["CocoaLink`"]

:Evaluate: CocoaObject::inval = "`1` is not a valid cocoa object"
:Evaluate: CocoaObject::argx = "Could not determine arguments from `1`"
:Evaluate: CocoaObject::mem = "You may not call memory management function `1`"
:Evaluate: CocoaObject::sel = "`1` does not respond to selector `2`"
:Evaluate: CocoaObject::conv = "Could not convert `1` to type `2`"
:Evaluate: CocoaObject::expt = "An exception (`1`) occurred: `2`"
:Evaluate: CocoaClass::inval = "`1` is not a valid class name"
:Evaluate: CocoaClass::alloc = "Instances of class `1` cannot be directly allocated"
:Evaluate: CocoaSelector::inval = "`1` is not a valid method name"
//:Evaluate: CocoaObjectPattern = CocoaObject[_Integer]
:Evaluate: CocoaObjectPattern = _Symbol

:Begin:
:Function: CocoaRun
:Pattern: CocoaRun[]
:Arguments: { }
:ArgumentTypes: { }
:ReturnType: Integer
:End:

:Begin:
:Function: cocoaClass
:Pattern: cocoaClass[name:(_String..)]
:Arguments: { name }
:ArgumentTypes: Manual
:ReturnType: Manual
:End:

:Begin:
:Function: CocoaClasses
:Pattern: CocoaClasses[]
:Arguments: { }
:ArgumentTypes: { }
:ReturnType: Manual
:End:

:Begin:
:Function: cocoaObjects
:Pattern: cocoaObjects[]
:Arguments: { }
:ArgumentTypes: { }
:ReturnType: Manual
:End:

:Begin:
:Function: CocoaObjectMethods
:Pattern: CocoaObjectMethods[obj:(CocoaObjectPattern..)]
:Arguments: { obj }
:ArgumentTypes: Manual
:ReturnType: Manual
:End:

:Begin:
:Function: CocoaSend
:Pattern: CocoaSend[obj_, selector_, args_List]
:Arguments: { obj, selector, args }
:ArgumentTypes: Manual
:ReturnType: Manual
:End:

:Begin:
:Function: CocoaAlloc
:Pattern: cocoaAlloc[class_, init_, args_List]
:Arguments: { class, init, args }
:ArgumentTypes: Manual
:ReturnType: Manual
:End:

:Begin:
:Function: CocoaObjectQ
:Pattern: CocoaObjectQ[obj:(CocoaObjectPattern..)]
:Arguments: { obj }
:ArgumentTypes: Manual
:ReturnType: Manual
:End:

:Begin:
:Function: CocoaObjectRelease
:Pattern: CocoaObjectRelease[obj:(CocoaObjectPattern..)]
:Arguments: { obj }
:ArgumentTypes: Manual
:ReturnType: Manual
:End:

:Begin:
:Function: CocoaObjectRefCount
:Pattern: CocoaObjectRefCount[obj:(CocoaObjectPattern..)]
:Arguments: { obj }
:ArgumentTypes: Manual
:ReturnType: Manual
:End:

:Begin:
:Function: cocoaObjectClass
:Pattern: cocoaObjectClass[obj:(CocoaObjectPattern..)]
:Arguments: { obj }
:ArgumentTypes: Manual
:ReturnType: Manual
:End:

:Begin:
:Function: cocoaObjectSuperclass
:Pattern: cocoaObjectSuperclass[obj:(CocoaObjectPattern..)]
:Arguments: { obj }
:ArgumentTypes: Manual
:ReturnType: Manual
:End:

:Begin:
:Function: CocoaObjectClasses
:Pattern: CocoaObjectClasses[obj:(CocoaObjectPattern..)]
:Arguments: { obj }
:ArgumentTypes: Manual
:ReturnType: Manual
:End:

:Begin:
:Function: CocoaObjectDescription
:Pattern: CocoaObjectDescription[obj:(CocoaObjectPattern..)]
:Arguments: { obj }
:ArgumentTypes: Manual
:ReturnType: Manual
:End:

:Begin:
:Function: cocoaToExpression
:Pattern: cocoaToExpression[obj:(CocoaObjectPattern..)]
:Arguments: { obj }
:ArgumentTypes: Manual
:ReturnType: Manual
:End:

:Begin:
:Function: cocoaDelegate
:Pattern: cocoaDelegate[ctx_, methods_]
:Arguments: { ctx, methods }
:ArgumentTypes: Manual
:ReturnType: Manual
:End:

:Begin:
:Function: CocoaData
:Pattern: cocoaData[str_String]
:Arguments: { str }
:ArgumentTypes: { ByteString }
:ReturnType: Manual
:End:

:Evaluate: EndPackage[]


int gArgc;
const char** gArgv;

int main(int argc, const char* argv[])
{
	gArgc = argc;
	gArgv = argv;
	
	// call this so we can make windows, etc.
	// we don't care if it fails, we just won't be able
	NSApplicationLoad();
	[[NSApplication sharedApplication] finishLaunching];
	
	return MLMain(argc, (char**) argv);
}
